<template>
    <view class="uni_calendar_box" @click="choiceDate(weeks)" v-if="nowDate==getTime(weeks.fullDate)">
        <view class="uni_calendar_box_item">
        	<view v-if="weeks.disable">
	        	<text class="uni_calendar_box_text_dis">{{ weeks.date }}</text>
        	</view>
        	<view v-else>
        		<!--有记录的点-->
	        	<block v-if="selected && weeks.extraInfo">
		        	<text class="uni_calendar_box_dian" v-if="newTime!=weeks.fullDate"></text>
		        	<text class="uni_calendar_box_dian" v-if="newTime==weeks.fullDate"></text>
		        	<!--选中-->
		        	<block v-if="calendar.fullDate==weeks.fullDate">
			        	<text class="uni_calendar_box_back uni_calendar_box_backa" v-if="newTime!=weeks.fullDate"></text>
			        	<text class="uni_calendar_box_back uni_calendar_box_backb" v-if="newTime==weeks.fullDate"></text>
		        		<text class="uni_calendar_box_text uni_calendar_box_textb">{{ weeks.date }}</text>
		        	</block>
		        	<!--未选中-->
		        	<block v-if="calendar.fullDate!=weeks.fullDate">
		        		<text class="uni_calendar_box_text uni_calendar_box_texta" v-if="newTime!=weeks.fullDate">{{ weeks.date }}</text>
		        		<text class="uni_calendar_box_text uni_calendar_box_textc" v-if="newTime==weeks.fullDate">{{ weeks.date }}</text>
		        	</block>
	        	</block>
	        	<!--无记录-->
	        	<block v-else>
	        		<block v-if="calendar.fullDate==weeks.fullDate">
			        	<text class="uni_calendar_box_back uni_calendar_box_backa" v-if="newTime!=weeks.fullDate"></text>
			        	<text class="uni_calendar_box_back uni_calendar_box_backb" v-if="newTime==weeks.fullDate"></text>
		        		<text class="uni_calendar_box_text uni_calendar_box_textb">{{ weeks.date }}</text>
	        		</block>
	        		<block v-if="calendar.fullDate!=weeks.fullDate">
		        		<text class="uni_calendar_box_text uni_calendar_box_texta">{{ weeks.date }}</text>
		        		<text class="uni_calendar_box_text uni_calendar_box_texta" v-if="newTime!=weeks.fullDate">{{ weeks.date }}</text>
		        		<text class="uni_calendar_box_text uni_calendar_box_textc" v-if="newTime==weeks.fullDate">{{ weeks.date }}</text>
	        		</block>
	        	</block>
        	</view>
        	<view class="uni_calendar_box_item_bir" v-if="birthday==weeks.fullDate">出生</view>
        </view>
    </view>
</template>

<script>
	import { formatDate } from '@/utils/utils'
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
export default {
    props: {
        weeks: {
            type: Object,
            default() {
                return {}
            }
        },
        calendar: {
            type: Object,
            default: () => {
                return {}
            }
        },
        selected: {
            type: Array,
            default: () => {
                return []
            }
        },
        lunar: {
            type: Boolean,
            default: false
        },
        nowDate:{
        	type: String,
        },
        birthday:{
        	type: String,
        }
    },
    data() {
        return {
            newTime: formatDate(new Date(), 'YYYY-MM-DD')
        }
    },
	  watch: {
	    nowDate(newVal) {
	      this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
	      this.weeks = this.cale.weeks
	    },
	  },
    methods: {
        choiceDate(weeks) {
            this.$emit('change', weeks)
        },
        getTime(date){
        	return formatDate(new Date(date), 'YYYY-MM')
        }
    }
}
</script>

<style lang="scss" scoped>
.uni_calendar_box {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.uni_calendar_box_item {
    position: relative;
    width: 100rpx;
    height: 110rpx;
    text-align: center;
    line-height: 100rpx;
    .uni_calendar_box_item_bir{
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 20rpx;
		color: #240000;
		line-height: 28rpx;
		text-align: center;
		font-style: normal;
		text-transform: none;
		position: absolute;
		bottom: 10rpx;
		left: 0;
		width: 100%;
    }
    .uni_calendar_box_text_dis{
    	color: #C0C0C0;
    }
    .uni_calendar_box_text{
    	position: absolute;
	    width: 100rpx;
	    height: 100rpx;
	    top: 0;
	    left: 0;
    	color: #333;
    }
    .uni_calendar_box_texta{
    	color: #333;
    }
    .uni_calendar_box_textb{
    	color: #fff;
    }
    .uni_calendar_box_textc{
    	color: #333;
    }
    .uni_calendar_box_dian{
	    position: absolute;
	    bottom: 0;
	    left: 50%;
	    margin-left: -7rpx;
	    width: 14rpx;
	    height: 14rpx;
	    border-radius: 8rpx;
	    background: #54CEAB;
    }
    .uni_calendar_box_back{
	    position: absolute;
	    top: 50%;
	    left: 50%;
	    margin-left: -39rpx;
	    margin-top: -43rpx;
	    width: 78rpx;
	    height: 78rpx;
	    border-radius: 50%;
    }
    .uni_calendar_box_backa{
	    background: #FDBA55;
    }
    .uni_calendar_box_backb{
	    background: #54CEAB;
    }
}

</style>